home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-11-06 | 1.4 KB | 62 lines | [TEXT/QED1] |
- /*
- Terminal 1.7
- "Sieve.s"
-
- This script was used to test the "Terminal" script interpreter. It is of no
- practical use. It is the standard sieve benchmark often used to test the
- performance of computers. Note that because the "Terminal" script language
- is an interpreted language it is rather slow for loop intensive operations,
- but for its intended purpose as a communications script language it is fast
- enough.
-
- The timing results were as follows (compared to the same program compiled
- with a real C compiler)
-
- Macintosh IIcx: 113 seconds (THINK C: 43.2 ms ==> 2616 times faster)
- Macintosh Plus: 527 seconds (THINK C: 271.0 ms ==> 1945 times faster)
-
- */
-
- int SIZE = 8191;
- int LAUF = 1;
- char FALSE = 0;
- char TRUE = 1;
-
- main()
- {
- int tick, iter, count, i, k, prime;
- char *flags, *p;
-
- display("Sieve benchmark %i passes\rThis may take several minutes...\r",
- LAUF);
- if (!(flags = new(SIZE))) {
- display("Not enough memory\r")
- return;
- }
- tick = time(); /* <====== start */
-
- for (iter = 0; iter < LAUF; ++iter) {
- count = 0;
- p = flags + SIZE;
- while (p > flags)
- *(--p) = TRUE;
- /* p == flags */
- for (i = 0; i < SIZE; ++i) {
- if (*p) {
- k = i + (prime = i + i + 3);
- while (k < SIZE) {
- flags[k] = FALSE;
- k = k + prime;
- }
- ++count;
- /*display("%i\r", prime);*/
- }
- ++p;
- }
- }
-
- tick = time() - tick; /* <====== stop */
- free(flags);
- display("%i primes in %i seconds\r", count, tick);
- }
-